package com.yanqu.road.server.manager.zhaoshang;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 玩家锁
 */
public class UserLockerMgr {

    private static Map<Long, Object> userLockerMap = new ConcurrentHashMap<>();

    public static Object getUserLocker(long userId){
        if(!userLockerMap.containsKey(userId)){
            synchronized (userLockerMap){
                if(!userLockerMap.containsKey(userId)){
                    userLockerMap.put(userId, new Object());
                }
            }
        }
        return userLockerMap.get(userId);
    }

}
